package com.producteev.version0.test;

import com.producteev4j.exceptions.ProducteevException;
import com.producteev4j.model.response.UserLogin;
import com.producteev4j.services.ProducteevService;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by IntelliJ IDEA.
 * User: jcarrey
 * Date: 14/05/11
 * TimeImpl: 17:07
 * To change this template use File | Settings | File Templates.
 */
public class ITTestActivityProducteevServices extends TestCase {

    private static ProducteevService service;

    @Before
    public void setUp() {
        if (service == null) {
            ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext-test.xml");
            service = (ProducteevService) applicationContext.getBean("service");
        }
    }


    private static final String EMAIL = "juankarrey@gmail.com";
    private static final String PASSWORD = "pr0duc733v4j";

    private static final long ID_DASHBOARD = 146402;
    private static final long ACTIVITY_ID = 18017080L;

    private static String userToken;


    @Test
    public void testUserLogin() throws ProducteevException {
        UserLogin userLogin = service.userLogin(EMAIL, PASSWORD);
        userToken = userLogin.getToken();
    }

    @Test
    public void testGetActivities() throws ProducteevException {
        service.getActivities(userToken, ID_DASHBOARD, ACTIVITY_ID, 1L);
    }

    @Test
    public void testGetNotifications() throws ProducteevException {
        service.getNotifications(userToken, ID_DASHBOARD, ACTIVITY_ID, 1L);
    }

    @Test
    public void testSetNotificationsRead() throws ProducteevException {
        service.setNotificationRead(userToken, ID_DASHBOARD, ACTIVITY_ID);
    }

}
